package org.nf.trading.config;

import org.nf.trading.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;


@Configuration
public class MvcConfig implements WebMvcConfigurer {
    /**
     * 跨域配置
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/connect")
                .allowedOrigins("*")
                .allowedMethods("*"); // 允许的 HTTP 方法
        //跨域时是否允许传递cookie，默认是不允许的
        //.allowCredentials(true);
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/api/user/user","/api/user/verifyToken");
    }
}